process.env.NODE_ENV="pack";
const webpack = require('webpack');
const merge = require('webpack-merge');
const conf=require('../conf.js');
const fs=require('fs');
const path=require('path');

var devstart=conf.yourApps[conf.dev.devStart];
var copy=conf.pack.copy;
var base = require('../base/index.js');
var packconfig = {
	output: {
		publicPath: "../"
	}
}

function cssCopy(name){
	console.log(name.name);
	var sourceFile=path.join(__dirname,"..","..",'dist','css',devstart+'.css');
	var destPath=name+'/'+devstart+'.css';
	var readStream = fs.createReadStream(sourceFile);
	var writeStream = fs.createWriteStream(destPath);
	readStream.pipe(writeStream);
	console.log('复制完成');
}
webpack(merge(base, packconfig), (err, stats) => {
	if(err) {
		console.log(err);
	}else if(copy&&copy.css){
		cssCopy(copy.css);
	}
})
